import screenfull from 'screenfull'

// JavaScript
const element = document.getElementById('target');
const button = document.getElementById('toggle');

button.addEventListener('click', () => {
    if (screenfull.isEnabled) { // 检查浏览器是否支持全屏
        screenfull.toggle(element); // 切换全屏状态
    } else {
        alert('你的浏览器不支持全屏模式');
    }
});

// 监听全屏状态变化
if (screenfull.isEnabled) {
    screenfull.on('change', () => {
        console.log('当前全屏状态:', screenfull.isFullscreen ? '全屏' : '非全屏');
    });
}